<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- Bootstrap CSS-->
    <%@include file="../assets/public.jsp"%>
    <title>文章</title>

</head>
<body>
<%@include file="../assets/header.jsp"%>

<div class="d-flex align-items-stretch">
    <!-- Sidebar Navigation-->
    <%@include file="../assets/sidebar.jsp"%>
    <!-- Sidebar Navigation end-->
    <div class="page-content">
        <div class="page-header">
            <div class="container-fluid">
                <h2 class="h5 no-margin-bottom">发布文章</h2>
            </div>
        </div>

        <section class="no-padding-bottom">

            <div class="list-group myList">
                <!--搜索文章的条件-->
                <div class="myTitle">
                    <form class="form-inline" action="${pageContext.request.contextPath}/article/article">
                        <div class="form-group">
                            <label for="inlineFormInput" class="sr-only">Name</label>
                            <c:if test="${sessionScope.articleTitle==''||sessionScope.articleTitle==null}">
                                <input id="inlineFormInput" name="articleTitle" type="text" placeholder="按标题名字查找" class="mr-sm-3 form-control">
                            </c:if>
                            <c:if test="${sessionScope.articleTitle!=''&&sessionScope.articleTitle!=null}">
                                <input id="inlineFormInput" name="articleTitle" type="text" value="${sessionScope.articleTitle}" class="mr-sm-3 form-control">
                            </c:if>
                        </div>
                        <div class="form-group">
                            <input type="submit" value="查询" class="btn btn-primary">
                        </div>
                    </form>

                    <input id = "addArt" type="button" value="发布文章" class="btn btn-primary">

                </div>

                <ul>
                    <c:forEach var="article" items="${sessionScope.ArticlepageEntity.data}">
                        <li class="list-group-item">

                            <a href="${pageContext.request.contextPath}/article/article_detail?articleId=${article.id}">${article.title}</a>
                            <c:if test="${sessionScope.userInfo.realName ==''||sessionScope.userInfo.realName == null}">
                                <p class="h6"><strong>作者：</strong>${sessionScope.userInfo.username}</p>
                            </c:if>
                            <c:if test="${sessionScope.userInfo.realName !=''&&sessionScope.userInfo.realName != null}">
                                <p class="h6"><strong>作者：</strong>${sessionScope.userInfo.realName}</p>
                            </c:if>
                            <p class="h6"><strong>时间：</strong>${article.publishDate}</p>
                            <p style="white-space:nowrap;overflow:hidden;text-overflow: ellipsis">${article.content}</p>
                        </li>
                    </c:forEach>

                </ul>

                <nav class="text-center" aria-label="Page navigation">
                    <ul class="pagination">
                        <li>
                            <a href="${pageContext.request.contextPath}/article/article_back" aria-label="Previous">
                                <span aria-hidden="true">&laquo;</span>
                            </a>
                        </li>
                        <c:forEach begin="${sessionScope.ArticlepageEntity.begin}" end="${sessionScope.ArticlepageEntity.end}" var="p" step="1">
                            <c:if test="${p==sessionScope.ArticlepageEntity.currPage}">
                                <li><a class="nav-active" href="${pageContext.request.contextPath}/article/article?currPage=${p}">${p}</a></li>
                            </c:if>
                            <c:if test="${p!=sessionScope.ArticlepageEntity.currPage}">
                                <li><a href="${pageContext.request.contextPath}/article/article?currPage=${p}">${p}</a></li>
                            </c:if>
                        </c:forEach>
                        <li>
                            <a href="${pageContext.request.contextPath}/article/article_next" aria-label="Next">
                                <span aria-hidden="true">&raquo;</span>
                            </a>
                        </li>
                    </ul>
                </nav>
            </div>
        </section>

        <%@include file="../assets/footer.jsp"%>
    </div>
</div>

</body>
</html>